//
//  ViewCartoonViewController.m
//  drawacartoon
//
//  Created by Ji Hu on 12-7-24.
//  Copyright (c) 2012年 爱辅导. All rights reserved.
//

#import "ViewCartoonViewController.h"
#import "File.h"
#import "ViewCartoonCell.h"

@interface ViewCartoonViewController ()

@end

@implementation ViewCartoonViewController

@synthesize titleLabel=_titleLabel;
@synthesize name=_name;
@synthesize viewCartoonDelegate=_viewCartoonDelegate;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

-(id)initWithName:(NSString *)name{
    
    self = [self initWithNibName:@"ViewCartoonViewController" bundle:nil];
    
    if (self!=nil) {
        
       self.name = name;
        
        NSString *path = [File oneCartoonPath:name];
        
        if (path!=nil) {
            NSFileManager *fm = [NSFileManager defaultManager];
            NSArray *images = [fm contentsOfDirectoryAtPath:path error:nil];
            self.tableViewDataArray = images;
        
        }
        
    }
    
    return self;
}

-(void)editClick:(id)sender{
    
    [self.viewCartoonDelegate edit:nil];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.titleLabel.text = self.name;
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

-(UITableViewCell *)basetableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NSString *iden = @"viewcartoon";
    
    ViewCartoonCell *cell = [self.tableView dequeueReusableCellWithIdentifier:iden];
    
    if (cell==nil) {
        cell =  [[ViewCartoonCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:iden];
    }
    
    
    
    return cell;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
	return YES;
}


@end
